Skip to content

fix(core): reject x-mcp-header on number-typed parameters - #2762

Draft
pcarleton wants to merge 1 commit into
mainfrom
paulc/x-mcp-header-reject-number
Draft

fix(core): reject x-mcp-header on number-typed parameters#2762
pcarleton wants to merge 1 commit into
mainfrom
paulc/x-mcp-header-reject-number

Conversation

@pcarleton

@pcarleton pcarleton commented Sep 6, 2026

Copy link
Copy Markdown
Member

Motivation and Context

The 2026-07-28 Streamable HTTP spec restricts x-mcp-header to primitive parameters, "MUST only be applied to parameters with primitive types (integer, string, boolean). Parameters with type number are not permitted", and requires clients to "reject tool definitions where any x-mcp-header value violates these constraints" by excluding the tool from tools/list.

PERMITTED_X_MCP_HEADER_TYPES in core-internal still allow-listed 'number'. The comment on it explains why: an older conformance fixture shipped type: "number" header parameters and expected clients to mirror them. That fixture was corrected in modelcontextprotocol/conformance#371 (the release this repo pins already uses integer), and modelcontextprotocol/conformance#444 adds the negative case, a number-typed x-mcp-header tool that a conforming client must drop, under the existing sep-2243-x-mcp-header-primitive-only check in the scored http-invalid-tool-headers scenario. With 'number' still permitted, this SDK would keep and call that tool and report a failure there once the conformance pin moves past 0.2.0-alpha.11. The python, go, csharp and rust SDKs already reject number.

What changed

  • packages/core-internal/src/shared/mcpParamHeaders.ts: drop 'number' from PERMITTED_X_MCP_HEADER_TYPES; replace the stale comment.
  • packages/core-internal/test/shared/mcpParamHeaders.test.ts: add "number-typed property is rejected" alongside the object/array/null cases.
  • Changeset (patch: core-internal, client, server).

The numeric comparison paths in validateMcpParamHeaders / mcpParamPrimitiveToString are untouched (they still serve integer).

How Has This Been Tested?

pnpm exec vitest run for core-internal/test/shared/mcpParamHeaders.test.ts (61 passed), client/test/client/mcpParamMirroring.test.ts (18), server/test/server/mcpParamValidation.test.ts (7); pnpm typecheck + pnpm lint in core-internal; pre-push build/typecheck/lint hooks green.

Breaking Changes

A tool whose inputSchema puts x-mcp-header on a type: "number" property is now treated as an invalid declaration (client: excluded from listTools(); server: registration rejected), as the spec requires. Use type: "integer" for numeric header parameters.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

The 2026-07-28 Streamable HTTP spec permits x-mcp-header only on
integer, string and boolean parameters and requires clients to exclude
tools that violate this. 'number' was allow-listed solely to pass an older
conformance fixture that used number-typed header parameters; that fixture
was corrected (modelcontextprotocol/conformance#371) and the conformance
suite is about to add a negative case for it (modelcontextprotocol/conformance#444).

Co-Authored-By: Claude <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e0e7b4b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/core-internal Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/server Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2762

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2762

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2762

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2762

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2762

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2762

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2762

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2762

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2762

commit: e0e7b4b

@JosephDoUrden JosephDoUrden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled e0e7b4b, 2817 passing across core-internal, client and server, typecheck and lint ok. Put 'number' back and only the new test fails. Conformance at the pinned alpha.11, 2026-07-28 legs, 385/385 client and 151/151 server.

One nit, mcpParamHeaders.ts:383 still checks decl.type === 'number', nothing reaches it now.

Looks merge-ready to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants